<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateBusinessPartnerTable extends Migrator
{
    public function change()
    {
        $this->table('business_partner', ['engine' => 'InnoDB', 'comment' => '商家信息表'])
            ->addColumn('main_id', 'integer', ['null' => false, 'default' => 0, 'comment' => '主键ID'])
            ->addColumn('business_type', 'string', ['limit' => 20, 'null' => false, 'default' => '', 'comment' => '商家类型:scenic景区,hotel酒店,restaurant餐饮,shopping购物'])
            ->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '商家名称'])
            ->addColumn('address', 'string', ['limit' => 255, 'null' => false, 'default' => '', 'comment' => '地址'])
            ->addColumn('contact_phone', 'string', ['limit' => 20, 'null' => false, 'default' => '', 'comment' => '联系电话'])
            ->addColumn('service_level', 'string', ['limit' => 20, 'null' => false, 'default' => 'normal', 'comment' => '服务等级:vip,normal'])
            ->addColumn('cooperation_status', 'integer', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '合作状态:0停用,1正常'])
            ->addColumn('area_desc', 'text', ['null' => true, 'comment' => '景区描述,主营简介'])
            ->addColumn('service_items', 'text', ['null' => true, 'comment' => '包含服务项目'])
            ->addColumn('service_content', 'text', ['null' => true, 'comment' => '服务内容'])
            ->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
            ->addColumn('deposit_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'null' => false, 'default' => '0.00', 'comment' => '预充值额度'])
            ->addColumn('is_open_direct', 'integer', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => '是否开通直营:0否,1是'])
            ->addIndex(['main_id'], ['name' => 'idx_main_id'])
            ->addIndex(['business_type'], ['name' => 'idx_business_type'])
            ->addIndex(['cooperation_status'], ['name' => 'idx_cooperation_status'])
            ->create();
    }
} 